package com.sgb.kjwl.view.ui.fragment.chat;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;

import com.sgb.kjwl.AppLazyFragment;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.FrChatAddressBookViewBinding;
import com.im.immodel.IMUtils;

/**
 * 消息-通讯录模块界面
 * Create by LiWei  2021/11/10
 */
public class ChatAddressBookFragment extends AppLazyFragment {

    private FrChatAddressBookViewBinding binding;

    public static ChatAddressBookFragment newInstance() {
        ChatAddressBookFragment dialog = new ChatAddressBookFragment();
        Bundle bundle = new Bundle();
        dialog.setArguments(bundle);
        return dialog;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = DataBindingUtil.inflate(inflater, R.layout.fr_chat_address_book_view, container, false);
        //viewModel = new ViewModelProvider(getActivity()).get(HomeCompanyConfigModel.class);
        return binding.getRoot();
    }

    @Override
    protected void initView() {
        binding.editSearch.setOnClickListener(this);

        Fragment fragment = IMUtils.getInstance().onBackContactBook(true);
        if (fragment != null) {
            getChildFragmentManager()
                    .beginTransaction()
                    .add(R.id.container, fragment)
                    .commitAllowingStateLoss();
        }
    }

    @Override
    protected void onLazyLoad() {

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.edit_search:
                IMUtils.getInstance().startSearch();
                break;
        }
    }
}
